package com.example.block_chain.controller.account;

import com.example.block_chain.common.ResponseResult;
import com.example.block_chain.domain.dto.LoginDto;
import com.example.block_chain.service.account.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/student/account/token/")
    public ResponseResult getToken(@RequestBody LoginDto dto, HttpSession session){
        String username = dto.getUsername();
        String password = dto.getPassword();
        return loginService.getToken(username,password,session);
    }

    @PostMapping("/admin/account/token/")
    public ResponseResult adminGetToken(@RequestBody LoginDto dto, HttpSession session){
        String username = dto.getUsername();
        String password = dto.getPassword();
        return loginService.adminGetToken(username,password,session);
    }
}
